#pragma once
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

const std::string gpipe_file = "./fifo"; //命名管道的路径
const mode_t gmode = 0600; //命名管道的权限
const int gsize = 1024;
const int gdefaultfd = -1;
const int OpenForRead = O_RDONLY;
const int OpenForWrite = O_WRONLY;

int OpenPipe(int flag)
{
    int fd = ::open(gpipe_file.c_str(), flag);
    if(fd < 0)
    {
        std::cerr << "open error" << std::endl;
    }
    return fd;
}

void ClosePipeHelper(int fd)
{
    if(fd >= 0)
        ::close(fd);
}